//
//  ViewController.swift
//  SwiftDemo
//
//  Created by sun on 2020/8/21.
//  Copyright © 2020 sun. All rights reserved.
//

import UIKit
import AVFoundation

class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let button = UIButton(type: .custom)
        button.setTitle("哈哈哈", for: .normal)
        button.backgroundColor = .red
        button.frame = CGRect(x: 100, y: 100, width: 100, height: 100)
        button.addTarget(self, action: #selector(buttonAction), for: .touchUpInside)
        view.addSubview(button)
    }
    
    @objc func buttonAction() {
        let videoURL = Bundle.main.path(forResource: "myMovie", ofType: "mp4")
        let asset = AVURLAsset(url: URL(fileURLWithPath: videoURL!))
        
        let timeRange = CMTimeRange(start: .zero, duration: asset.duration)
        VideoManager.exportEditVideo(form: asset, timeRange: timeRange, cropFrame: CGRect(x: 0, y: 400, width: 1080, height: 1080), orignalSize: CGSize(width: 1920, height: 1080))
            
        
        
    }
}
